Skip to content

Add models of various aligned_allocs#21725

Merged
jketema merged 3 commits intomainfrom
jeongsoolee09/add-aligned-alloc-model
Apr 17, 2026
Merged

Add models of various aligned_allocs#21725
jketema merged 3 commits intomainfrom
jeongsoolee09/add-aligned-alloc-model

Conversation

@jeongsoolee09
Copy link
Copy Markdown
Contributor

Add models of aligned_alloc, available in several ways:

  1. ::aligned_alloc, defined in stdlib.h: reference
  2. std::aligned_alloc, defined in cstdlib: reference
  3. bsl::aligned_alloc, defined here.

@jeongsoolee09 jeongsoolee09 requested a review from a team April 17, 2026 01:26
@jeongsoolee09 jeongsoolee09 requested a review from a team as a code owner April 17, 2026 01:26
Copilot AI review requested due to automatic review settings April 17, 2026 01:26
@github-actions github-actions bot added the C++ label Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the C/C++ allocation modeling to include aligned_alloc across common namespaces (global C, std, and Bloomberg bsl), enabling CodeQL’s allocation reasoning to recognize these APIs as heap allocators that require deallocation.

Changes:

  • Add allocation models for ::aligned_alloc, std::aligned_alloc, and bsl::aligned_alloc with the allocation-size argument mapped to parameter index 1.
  • Keep existing standard allocation models (malloc, calloc, alloca, etc.) unchanged.
Show a summary per file
File Description
cpp/ql/lib/ext/allocation/Std.allocation.model.yml Adds aligned_alloc entries to the allocationFunctionModel extension for global/std/bsl namespaces.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@jeongsoolee09
Copy link
Copy Markdown
Contributor Author

I have searched for tests of allocationFunctionModel but have not found any.

Copy link
Copy Markdown
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. One comment below. Running DCA on this before approving.

Comment thread cpp/ql/src/change-notes/2026-04-16-add-model-for-aligned-alloc.md Outdated
@geoffw0
Copy link
Copy Markdown
Contributor

geoffw0 commented Apr 17, 2026

I have searched for tests of allocationFunctionModel but have not found any.

There are some tests in cpp/ql/test/library-tests/allocators (there are also tests for the various memory management queries, and they provide coverage for more of the variant allocators).

Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Apr 17, 2026

I have searched for tests of allocationFunctionModel but have not found any.

There are some tests in cpp/ql/test/library-tests/allocators (there are also tests for the various memory management queries, and they provide coverage for more of the variant allocators).

I don't think we have been consistently adding tests there for each and every allocation function. If only because there are too many of them.

Copy link
Copy Markdown
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DCA looks ok. There's one new TP result. I don't really understand why this shows up after this change, as aligned_alloc is not being used (it does occur in the codebase), but I don't think it's worth further investigating this.

Thanks for the contribution.

@jketema jketema merged commit 3073c1c into main Apr 17, 2026
16 checks passed
@jketema jketema deleted the jeongsoolee09/add-aligned-alloc-model branch April 17, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants